﻿<%@ Page Title="View Product Page" Language="C#" MasterPageFile="  ~/template/Site.Master" AutoEventWireup="true" CodeBehind="ViewProduct.aspx.cs" Inherits="EAAdmin.ViewProduct" %>

<%@ Import Namespace="EA.DTO" %>
<%@ Import Namespace="EA.Common" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <form id="form1" runat="server">
        <div class="page_name">List of Product</div>
         <div class="error">
            <%                
                String alert = "";
                if (Attributes.ContainsKey("err"))
                {
                    alert = (String)Attributes["err"];
            %>
            <div class="message">
                <div><%=alert%></div>
            </div>
            <%  }
                if (Attributes.ContainsKey("success"))
                {
                    alert = (String)Attributes["success"];
            %>
            <div class="message_alert">
                <div><%=alert%></div>
            </div>
            <%  } %>
        </div>
        <table class="table">
            <tr>
                <th>Id</th>
                <th>Name</th>
                <th>Detail</th>
                <th>Floor Price</th>
                <th>Step Price</th>
                <th>Current Price</th>
                <th>Begin Date</th>
                <th>Total BidDay</th>
                <th>Status</th>
            </tr>
            <% List<ProductTO> listProduct = (List<ProductTO>)Attributes["listProduct"]; %>
            <%
                for (int i = 0; i < listProduct.Count; i++)
                {  
            %>
            <tr>
                <td><%=listProduct[i].ID%></td>
                <td><%= listProduct[i].Name %></td>
                <td><%= listProduct[i].Detail %></td>
                <td><%=listProduct[i].FloorPrice %></td>
                <td><%=listProduct[i].StepPrice %></td>
                <td><%=listProduct[i].CurrentPrice %></td>
                <td><%=listProduct[i].BeginDate.ToString("dd/MM/yyyy hh:mm") %></td>
                <td><%=listProduct[i].TotalBidDay %></td>
                <td>
                    <% if (listProduct[i].Status == Constant.PRODUCT_ACTIVE_AUCTION)
                       {%>
                    <a>Active</a>
                    <% }
                       else if (listProduct[i].Status == Constant.PRODUCT_PENDING_APPROVAL)
                       {%>
                    <a style="color: orange">Pending approval</a>
                    <% } %>

                    <% if (listProduct[i].Status == Constant.PRODUCT_PENDING_APPROVAL)
                       {%>
                    <a href="/ViewProduct.aspx?action=Delete&id=<%=listProduct[i].ID %>" style="margin-right: 5px; float: right">
                        <img src="/public/images/cross.png" />
                    </a>

                    <a href="/EditProduct.aspx?id=<%=listProduct[i].ID %>" style="margin-right: 5px; float: right">
                        <img src="/public/images/pencil.png" />
                    </a>
                    <%}%>
                </td>
            </tr>
            <% } %>
        </table>

        <%int total = (Int32)Attributes["totalProduct"];
          int totalView = Constant.TOTAL_RECORD_VIEW;
          double page = (double)total / (double)totalView;
          if (page > (int)page)
          {
              page = page + 1;
          }
        %>
        <div>
            <div>Page</div>
            <select onchange="location.href='/ViewProduct.aspx?page='+this.value;">
                <% 
                    for (int i = 1; i < page; i++)
                    { 
                %>
                <option <%= ( ((int)Attributes["page"]) == i ) ? "selected" : "" %> value="<%=i %>">
                    <%=i %>
                </option>
                <%  
                                }
                %>
            </select>
        </div>
    </form>
</asp:Content>
